/**
 * @summary 搜索请求模块
 */

import req from '@/utils/request';
import * as URL from '@/constants/api';

export function getSuggestionList(searchValue) {
  return req({
    url: URL.SUGGESTION_LIST,
    params: {
      q: searchValue,
    },
  })
    .then((res) => res.data.data.options.filter(o => o?.trim()))
    .catch(() => []);
}

export function getSearchResult(searchValue) {
  return req({
    url: URL.SEARCH,
    params: {
      q: searchValue,
    },
  })
    .then((res) => res.data.data.results)
    .catch(() => null);
}

// deadline
